﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Pseudogenerator.Common.Generators.Core;

namespace Pseudogenerator.Common.Generators
{
    public class MitchellMoore
        : MethodBase
    {
        public uint n { get; set; }

        public override bool CanGenerateNext
        {
            get { return n>54 && m%2==0; }
        }

        public override uint GetNextValue()
        {
            throw new NotImplementedException();
        }

        public override List<RandomNumber> GetFullList()
        {
            Fibonacci f = new Fibonacci();
            f.x_1 = 0;
            f.x0 = 1;
            f.m = n;

            var nums = new List<RandomNumber>();
            var vectorMoore = new List<RandomNumber>(f.GetFullList());
            
            for (int i = 0; i < m; i++) 
            {
                var xn24 = (vectorMoore[(vectorMoore.Count - 1) - 24].Uniform) * n;
                var xnn = (vectorMoore[vectorMoore.Count - (int)n].Uniform) * n;
                var r = (xn24 + xnn) % m;
                var resultado = r;
                vectorMoore.Add(new RandomNumber(m) { n = (uint)i, Xn = (uint)resultado });
                nums.Add(new RandomNumber(m) { n = (uint)i, Xn = (uint)resultado });               
            }     
            return nums;
        }

        public override string ToString()
        {
            return string.Format("n={0}, m={1}", n, m);
        }
    }
}
